package com.hq.ims.data.vo;

import com.hq.authority.utils.AppUtils;
import com.hq.ims.data.config.verification.VdAdd;
import com.hq.ims.data.config.verification.VdEdit;
import com.hq.ims.data.entity.CompanyEmployee;
import com.hq.ims.data.vo.auth.BaseRowAuthVo;
import com.hq.utils.util.ListUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;


/**
 * @author 蒋柏平
 * @since 20240927
 */
@Mapper
public interface CompanyEmployeeMapstruct {

    CompanyEmployeeMapstruct INSTANCE = Mappers.getMapper(CompanyEmployeeMapstruct.class);

    //-------------------------------- 转换VO类 --------------------------------


    @Mappings({
    })
    CompanyEmployeeVo toCompanyEmployeeVo(CompanyEmployee source);

    default List<CompanyEmployeeVo> toCompanyEmployeeVoList(List<CompanyEmployee> source) {
        if (source == null) {
            return ListUtils.newEmptyList();
        }
        return source.stream().map(this::toCompanyEmployeeVo).collect(Collectors.toList());
    }

    //-------------------------------- 以下为自定义类[输出对象] --------------------------------

    @ApiModel(value = "原始对象的扩展类")
    @Data
    class CompanyEmployeeVo extends CompanyEmployee {

    }

    @ApiModel(value = "行级权限对象")
    @Data
    class CompanyEmployeeRowAuthVo extends BaseRowAuthVo {

        //自定义其它行级权限


        //构造函数
        public CompanyEmployeeRowAuthVo(CompanyEmployee entity) {
            //当前操作用户ID
            String userId = AppUtils.getUserId();
        }

    }


    //-------------------------------- 以下为自定义类[输入对象] --------------------------------

    @ApiModel(value = "搜索VO")
    @Data
    class PageSearchVo {

            @NotBlank(message = "公司ID")
            private String companyId;

            @NotBlank(message = "用户姓名")
            private String realName;

    }

    @ApiModel(value = "添加和修改对象")
    @Data
    class SaveVo {

        @NotBlank(message = "数据ID不能为空", groups = {VdEdit.class})
        @ApiModelProperty(value = "数据ID")
        private String companyEmployeeId;

        @ApiModelProperty(value = "创建时间 - 不需程序员处理")
        private LocalDateTime createDateTime;

        @ApiModelProperty(value = "版本号")
        private Integer version;

        @ApiModelProperty(value = "更新时间 - 不需程序员处理")
        private LocalDateTime updateDateTime;

        @NotBlank(message = "创建用户名称不能为空", groups = {VdAdd.class, VdEdit.class})
        @Size(min = 1, max = 100, message = "创建用户名称长度不能超过100", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "创建用户名称")
        private String createUserName;

        @NotBlank(message = "更新用户名不能为空", groups = {VdAdd.class, VdEdit.class})
        @Size(min = 1, max = 100, message = "更新用户名长度不能超过100", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "更新用户名")
        private String updateUserName;

        @NotBlank(message = "公司ID(关联company)不能为空", groups = {VdAdd.class, VdEdit.class})
        @Size(min = 1, max = 36, message = "公司ID(关联company)长度不能超过36", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "公司ID(关联company)")
        private String companyId;

        @ApiModelProperty(value = "公司名称")
        private String companyName;

        @ApiModelProperty(value = "部门id(关联company_department)")
        private String departmentId;

        @ApiModelProperty(value = "部门名称")
        private String departmentName;

        @NotBlank(message = "用户ID(关联user)不能为空", groups = {VdAdd.class, VdEdit.class})
        @Size(min = 1, max = 36, message = "用户ID(关联user)长度不能超过36", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "用户ID(关联user)")
        private String userId;

        @NotNull(message = "是否系统管理员不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "是否系统管理员")
        private Boolean isAdmin;

        @NotNull(message = "是否离开公司不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "是否离开公司")
        private Boolean isResign;

        @NotNull(message = "是否为兼职不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "是否为兼职")
        private Boolean isPartTimeJob;


    }

    //-------------------------------- springboot验证标识 --------------------------------

}
